#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
class Solution {
public:
    vector<string> findRelativeRanks(vector<int>& score) {
        vector<string> answer;
        answer.resize(score.size());
        vector<int> ret(score);
        sort(ret.begin(), ret.end());
        int count = 1;
        for (int i = ret.size() - 1; i >= 0; i--)
        {
            for (int j = 0; j < score.size(); j++)
            {
                if (count == 1 && ret[i] == score[j])
                {
                    answer[j] = "Gold Medal";
                }
                else if (count == 2 && ret[i] == score[j])
                {
                    answer[j] = "Silver Medal";
                }
                else if (count == 3 && ret[i] == score[j])
                {
                    answer[j] = "Bronze Medal";
                }
                else if (ret[i] == score[j])
                {
                    answer[j] = to_string(count);
                }

            }
            count++;
        }
        return answer;
    }
};


int main()
{
    vector<int> score = { 5,4,3,2,1 };
    findRelativeRanks(score);
    return 0;
}


class Solution {
public:
    vector<string> findRelativeRanks(vector<int>& score) {
        int n = score.size();

        vector<string> answer(n);
        vector<pair<int, int>> ret;
        for (int i = 0; i < n; i++)
        {
            ret.push_back({ score[i],i });
        }
        sort(ret.begin(), ret.end(), std::greater<>());
        for (int i = 0; i < n; i++)
        {
            if (0 == i)
            {
                answer[ret[i].second] = "Gold Medal";
            }
            else if (1 == i)
            {
                answer[ret[i].second] = "Silver Medal";
            }
            else if (2 == i)
            {
                answer[ret[i].second] = "Bronze Medal";
            }
            else {
                answer[ret[i].second] = to_string(i + 1);
            }
        }
        return answer;

    }
};